// Copyright (C) 1998-2008, Sumisho Computer Systems Corp. All Rights Reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @author Hitoshi Okada
 */

package com.curlap.orb.generator;

import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;

/**
 * JarFileProperty
 */
public class JarFileProperty implements java.io.Serializable 
{
	private static final long serialVersionUID = 1L;

    private String jarFileName;
    private List<PackageProperty> packageProperties;

    // constructors
    public JarFileProperty(String jarFileName)
    {
        this.jarFileName = jarFileName;
        this.packageProperties = new ArrayList<PackageProperty>();
    }

    public JarFileProperty(String jarFileName, List<PackageProperty> packageProperties)
    {
        this.jarFileName = jarFileName;
        this.packageProperties = packageProperties;
    }

    // getter/setter
    public String getJarFileName()
    {
        return jarFileName;    
    }
    public void setJarFileName(String jarFileName)
    {
        this.jarFileName = jarFileName;
    }

    public PackageProperty[] getPackageProperties()
    {
        return packageProperties.toArray(new PackageProperty[packageProperties.size()]);
    }
    public void setPackageProperties(PackageProperty[] packageProperties)
    {
        this.packageProperties = Arrays.asList(packageProperties);
    }
    
    // methods
    public void addPackageProperty(PackageProperty packageProperty)
    {
        packageProperties.add(packageProperty);    
    }

    public PackageProperty getPackageProperty(String packageName)
    {
        // HACK!
        for (int i = 0; i < packageProperties.size(); i++)
        {
            PackageProperty p = packageProperties.get(i);
            if (p.getName().equals(packageName))
            {
                return p;   
            }
        }
        return null;
    }
}
